<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>${metadata.alias!}</title>
    <style type="text/css">
        .right{float:right;}
        .gray{color:gray;}
        .border{border:1px solid gray;}
        .underline{border-bottom:1px dashed gray;}
    </style>
</head>
<body>
    <header data-diy="page">
        <h1>${(site.name)!}</h1>
    </header>
    <nav data-diy="category">
        <a href="${site.dynamicPath}">Home</a>
<@cms.categoryList>
    <#list page.list as a>
        <a href="${a.url!}" target="_blank" data-diy-item="${a.id}">${a.name}</a>
    </#list>
</@cms.categoryList>
    </nav>
    <main>
        <#macro message code>${springMacroRequestContext.getMessage(code)}</#macro>
    <@trade.refundList userId=user.id pageIndex=pageIndex pageSize=10>
        <h3>Refunds</h3>
        <ul>
        <#list page.list as a>
            <li class="underline">
                <p><@message 'page.status.refund.'+a.status/><span class="right">${a.createDate!}</span></p>
                <p class="gray"><label>Order id:</label>${a.orderId!} <label>Apply amount:</label>${a.amount!} <label>Refund amount:</label>${a.refundAmount!}</p>
                <p>${a.reason!}<span class="right"><label>Replay:</label>${a.reply!}</span></p>
                <#if 0=a.status||3=a.status>
                    <form action="${site.dynamicPath}tradePayment/refund" method="POST">
                        <input type="hidden" name="_csrf" value="<@tools.csrfToken/>"/>
                        <input type="hidden" name="id" value="${a.id}"/>
                        <input type="hidden" name="returnUrl" value="${site.dynamicPath}paymentList.html"/>
                        <input type="hidden" name="paymentId" value="${a.id}"/>
                        <label>Amount:</label><input type="text" name="amount" required="required" value="${a.amount!}" max="${a.amount}"/>
                        <label>Reason:</label><input type="text" name="reason" required="required" value="${a.reason!}"/>
                        <input type="submit" value="Update"/>
                    </form>
                </#if>
            </li>
        </#list>
        </ul>
        <div>
            <#assign
                start=1
                end=page.totalPage
            />
            <#if (page.pageIndex-5) gt start>
                <#assign start=page.pageIndex-4/>
            </#if>
            <#if (page.pageIndex+5) lt end>
                <#assign end=page.pageIndex+4/>
            </#if>
            <#if !page.firstPage>
                <a href="${getPage('refund.html',page.prePage,'pageIndex')}">Previous page</a>
            <#else>
                <span>Previous page</span>
            </#if>
            <#if start gt 1>
                <a href="${'refund.html'}">1</a> ...
            </#if>
            <#list start..end as n>
                <#if n=page.pageIndex>
                    ${n}
                <#else>
                    <a href="${getPage('refund.html',n,'pageIndex')}">${n}</a>
                </#if>
            </#list>
            <#if end lt page.totalPage>
                ... <a href="${getPage('refund.html',page.totalPage,'pageIndex')}">${page.totalPage}</a>
            </#if>
            <#if !page.lastPage>
                <a href="${getPage('refund.html',page.nextPage,'pageIndex')}">Next page</a>
            <#else>
                <span>Next page</span>
            </#if>
        </div>
    </@trade.refundList>
    </main>
    <footer>
        Copyright &copy; ${.now?string('yyyy')}
    </footer>
    <script>
    var itemString="itemType=user&itemId=${user.id}";
    var templatePath='${.current_template_name?keep_after('/')}';
    </script>
    <script src="${site.dynamicPath}resource/js/cms.support.js"></script>
    <script>
        var ca = cmsAnalytics();
        var url='${site.dynamicPath}api/visit/record';
        if("string" ==typeof itemString){
            url=url+"?"+itemString;
        }
        ca.setDomain('${site.sitePath?keep_after('//')?keep_before('/')?keep_before(':')}');
        ca.setPath('/');
        ca.report(url);
    </script>
</body>
</html>